<template>
	<div>
		<NavigationBar :title="info.name"></NavigationBar>
		<Comment :info="info" v-if="curSelColumn==1"></Comment>
	</div>
	
</template>

<script>
	import NavigationBar from './pages/NavigationBar.vue'
	import Comment from './pages/Comment.vue'
	import HttpUtil from '../js/HttpUtil.js'
	import UserInfoManager from "../js/UserInfoManager.js"
	
	export default {
		metaInfo() {
			return {
				title: this.info.name + '-' + '在线漫画-火漫画官方网站',
				meta: [{
						name: 'Keywords',
						content: this.info.name + '漫画,' + this.info.name + '全集,' + this.info.name + '漫画全集,' + this.info.typeName +
							'在线漫画,' + this.info.typeName + ',火漫画画,火漫画官方网站'
					}, {
						name: 'Description',
						content: this.info.desciption
					}
				]
			}
		},
		components: {
			// Header,
			// Footer,
			NavigationBar,
			Comment
		},
		data() {
			return {
				loadStatusText: '',
				detailStatus: 0,
				productId: this.$route.query.productId,
				RelevantList: [],
				isReverseOrder: false,
				info: {
					name: "评论详情",
					desciption: "",
					thumUrl: "",
					productId: this.$route.query.productId,
					isReverseOrder: false,
				},
				rows: 0,
				isMobile: false,
				curSelColumn: 1,
				firstCharptId: 0,
				
			}
		},
		mounted() {
			//此界面不能缩放
			var viewports=	document.getElementsByName("viewport");
			console.log("viewports="+viewports);
			for (var i = 0; i < viewports.length; i++) {
				viewports[i].content ="width=device-width,initial-scale=1.0, minimum-scale=1.0,maximum-scale=1.0, user-scalable=no";
			}
			let productId = this.$route.query.productId;
			//let curSelColumn = this.$route.query.curSelColumn;
			if (productId) {
				this.productId = productId;
				// this.$refs.ChapterList.reloadData(productId)
			}
	
			this.requstdetail()
			// this.requestExtensionInfo()
			if (this._isMobile()) {
				this.isMobile = true;
				console.log('是手机')
			} else {
				console.log('是PC')
				this.isMobile = false;
			}
		},
		methods: {
			
			requstdetail: function() {
				var params1 = new URLSearchParams();
				let productId = this.productId
				if (productId) {
					params1.append('productId', productId);
				}
				let that = this
				//详情
				HttpUtil.post('product/detail.do', params1)
					.then(response => {
						// console.log('详情：' + JSON.stringify(response.data));
	
						if (response.data.code == 0) {
							let data = response.data.data;
							let info = data.info;
							that.RelevantList = data.RelevantList
							that.info = info;
							that.detailStatus = 1;
							that.firstCharptId = data.firstCharptId;
	
						} else {
							that.detailStatus = -1;
						}
					})
					.catch(function(error) {
						console.log(error);
						that.detailStatus = -1;
					});
			},
			
			getLoadStatus: function(curRow) {
				if (this.detailStatus == 0) {
					this.loadStatusText = '正在努力加载···'
					return 0; //正在加载
				} else if (this.detailStatus == 1) {
					this.loadStatusText = ''
					return 1; //加载完成
				} else {
					this.loadStatusText = 'o(╥﹏╥)o  加载失败!，请刷新页面'
					return 2; //部分加载完成
				}
			},
			
			_isMobile() {
				console.log('测试。。。。')
				console.log(navigator.userAgent)
				let flag = navigator.userAgent.match(
					/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i
				)
				return flag;
			}
		},
		beforeRouteLeave(to, from, next) {
			//console.log("to:"+JSON.stringify(to))
			//离开路由到首页，首页不能刷新
			if (to.path == '/' || to.path == '/Home') {
				to.meta.isUseCache = true;
				console.log('首页需要使用缓存数据')
			} else {
				console.log('首页不需要使用缓存数据')
			}
			next();
		},
		computed: {
			key() {
				return this.$router.path + Math.random();
			}
		}
	
	}
</script>

<style>
</style>
